home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / S-ICE252.ZIP / SAMPLE.ASM < prev    next >
Assembly Source File  |  1989-03-22  |  2KB  |  96 lines

  1.     Page    55,80
  2.     Title    Sample program for Soft-ICE tutorial
  3.  
  4. CODE    Segment Public    'Code'
  5. CODE    Ends
  6.  
  7. DATA    Segment Public    'Data'
  8.  
  9. public pad,char,answer,space_msg,no_space_msg
  10.  
  11. pad        db 12H dup(0)
  12. char        db 0
  13. answer        db 0
  14. space_msg    db 'The Character is a SPACE',0DH,0AH,'$'
  15. no_space_msg    db 'The Character is NOT a SPACE',0DH,0AH,'$'
  16. DATA    Ends
  17.  
  18. STACK    Segment Stack    'Stack'
  19.  
  20.     Dw    128 Dup (?)        ;Program stack
  21.  
  22. STACK    Ends
  23.  
  24. CODE    Segment Public    'Code'
  25.  
  26.     Assume    CS:CODE,DS:DATA,ES:Nothing,SS:STACK
  27.  
  28. public start,main_loop,no_space,get_key,is_space?,not_space,hang_example
  29.  
  30. start:
  31.  
  32. ; Set up segments
  33.  
  34.     mov    ax,DATA         ;ax = DATA segment
  35.     mov    es,ax            ;es = DATA segment
  36.     mov    ds,ax            ;ds = DATA segment
  37.  
  38. ; Main Program Loop
  39.  
  40. main_loop:
  41.  
  42.     call    get_key         ;call Jake's get key routine
  43.     call    is_space?        ;call Jake's is_space routine
  44.     cmp    answer,0        ;was it a space?
  45.     je    no_space        ;no - go print not a space message
  46.  
  47. ; Its a space, display the space message
  48.  
  49.     mov    ah,9            ;ah = DOS display string function
  50.     mov    dx,offset space_msg    ;dx -> space message
  51.     int    21H            ;call DOS
  52.     jmp    main_loop        ;jump back to the main loop
  53.  
  54. ; Its not a space, display the no space message
  55.  
  56. no_space:
  57.     mov    ah,9            ;ah = DOS display string function
  58.     mov    dx,offset no_space_msg    ;dx -> not a space message
  59.     int    21H            ;call DOS
  60.     jmp    main_loop        ;jump back to the main loop
  61.  
  62. ; Get Key Routine
  63.  
  64. get_key     proc
  65.     mov    ah,8            ;ah = DOS get key function
  66.     int    21H            ;call DOS
  67.     mov    char,al         ;store byte in variable char
  68.     ret                ;return from this routine
  69. get_key     endp
  70.  
  71. ; Check to see if the character is a space
  72.  
  73. is_space?    proc
  74.     cmp    char,20H        ;is the character a space?
  75.     jne    not_space        ;no - go do funny business
  76.     mov    answer,1        ;yes - return 1 in variable answer
  77.     ret                ;return from this routine
  78. not_space:
  79. assume cs:data                ;required to produce bizzar bug
  80.     mov    cs:answer,0        ;return 0 in variable answer
  81. assume cs:code
  82.     ret                ;return from this routine
  83. is_space?    endp
  84.  
  85. ; The following routine is an infinite loop with interrupts disabled
  86.  
  87. hang_example:
  88.     cli                ;disable interrupts
  89.     jmp    $            ;infinite loop
  90.  
  91.     mov    ax,4c00h        ;ax = DOS exit command
  92.     int    21h            ;call MSDOS
  93.  
  94. CODE    Ends
  95.     End    start
  96.